package org.jeecg.modules.room.controller;

import org.jeecg.common.api.vo.Result;
import org.jeecg.common.util.UUIDGenerator;
import org.jeecg.modules.room.entity.RoomBookRoom;
import org.jeecg.modules.room.entity.RoomInfo;
import org.jeecg.modules.room.service.IRoomBookRoomService;
import lombok.extern.slf4j.Slf4j;
import org.jeecg.common.system.base.controller.JeecgController;
import org.jeecg.modules.room.vo.RoomAddFpVo;
import org.jeecg.modules.room.vo.RoomBookInfoVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.jeecg.common.aspect.annotation.AutoLog;

import java.util.List;

/**
 * @Description: 预定单和房间号对应表
 * @Author: jeecg-boot
 * @Date:   2023-12-18
 * @Version: V1.0
 */
@Api(tags="预定单和房间号对应表")
@RestController
@RequestMapping("/room/roomBookRoom")
@Slf4j
public class RoomBookRoomController extends JeecgController<RoomBookRoom, IRoomBookRoomService> {
	@Autowired
	private IRoomBookRoomService roomBookRoomService;

	 /**
	  *
	  * @param roomAddFpVo
	  * @return
	  */
	@AutoLog(value = "手动分房")
	@ApiOperation(value="手动分房", notes="手动分房")
	@PostMapping(value = "/addFp")
	public Result<String> addFp(@RequestBody RoomAddFpVo roomAddFpVo) {
		roomBookRoomService.addFp(roomAddFpVo.getBookMxIds(),roomAddFpVo.getRoomCodeList(),roomAddFpVo.getBookCode());
		return Result.OK("添加成功！");
	}

	 /**
	 *   预定自动分配房间
	 *
	 * @param bookMxIds
	 * @return
	 */
	@AutoLog(value = "预定自动分配房间")
	@ApiOperation(value="预定自动分配房间", notes="预定自动分配房间")
	@RequestMapping(value = "/autoFpRoom")
	public Result<String> autoFpRoom(@RequestParam(name="bookMxIds",required=true) String bookMxIds,
									 @RequestParam(name="bookCode",required=true) String bookCode) {
		roomBookRoomService.autoFpRoom(bookMxIds,bookCode);
		return Result.OK("自动分配成功！");
	}


	/**
	 *   预定自动分配房间
	 *
	 * @param bookCodes
	 * @return
	 */
	@AutoLog(value = "预定自动分配房间")
	@ApiOperation(value="预定自动分配房间", notes="预定自动分配房间")
	@RequestMapping(value = "/autoFpRoomByBookCode")
	public Result<String> autoFpRoomByBookCode(@RequestParam(name="bookCodes",required=true) String bookCodes) {
		roomBookRoomService.autoFpRoomByBookCode(bookCodes);
		return Result.OK("自动分配成功！");
	}
	
	/**
	 *  编辑
	 *
	 * @param roomBookRoom
	 * @return
	 */
	@AutoLog(value = "预定单和房间号对应表-编辑")
	@ApiOperation(value="预定单和房间号对应表-编辑", notes="预定单和房间号对应表-编辑")
	@RequestMapping(value = "/edit", method = {RequestMethod.PUT,RequestMethod.POST})
	public Result<String> edit(@RequestBody RoomBookRoom roomBookRoom) {
		roomBookRoomService.updateById(roomBookRoom);
		return Result.OK("编辑成功!");
	}
	
	/**
	 *   取消分房
	 *
	 * @param bookMxIds
	 * @return
	 */
	@AutoLog(value = "取消分房")
	@ApiOperation(value="取消分房", notes="取消分房")
	@RequestMapping(value = "/cancelFp")
	public Result<String> cancelFp(@RequestParam(name="bookMxIds",required=true) String bookMxIds,
								   @RequestParam(name="bookCode",required=true) String bookCode) {
		roomBookRoomService.cancelFp(bookMxIds,bookCode);
		return Result.OK("取消成功!");
	}

	/**
	 *   取消分房
	 *
	 * @param bookCodes
	 * @return
	 */
	@AutoLog(value = "取消分房")
	@ApiOperation(value="取消分房", notes="取消分房")
	@RequestMapping(value = "/cancelFpByBookCode")
	public Result<String> cancelFpByBookCode(@RequestParam(name="bookCodes",required=true) String bookCodes) {
		roomBookRoomService.cancelFpByBookCode(bookCodes);
		return Result.OK("取消成功!");
	}


}
